#!/bin/bash
source /etc/profile

dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -uroot -proot -hhadoop2<<EOF
select A.EVALUATION_ID,B.OLDUNIQUEID,C.name,A.TIME,
A.STAR4,A.STAR3,A.STAR,A.CONTENT
from 
(SELECT EVALUATION_ID,TIME,STAR4,STAR3,STAR,CONTENT,customer_id,ORG_ID from oracleanditem.TBL_EVALUATION where TIME>'$dt') AS A 
join oracleanditem.TBL_ORGANIZATION AS B 
ON B.ID = A.ORG_ID
JOIN oracleanditem.TBL_CUSTOMER AS C
ON A.customer_id = C.customer_id 
union all
select A.EVALUATION_ID,B.OLDUNIQUEID,C.name,A.TIME,
A.STAR4,A.STAR3,A.STAR,A.CONTENT
from 
(SELECT EVALUATION_ID,TIME,STAR4,STAR3,STAR,CONTENT,customer_id,ORG_ID from oraclecd.TBL_EVALUATION where TIME>'$dt') AS A 
join oraclecd.TBL_ORGANIZATION AS B 
ON B.ID = A.ORG_ID
JOIN oraclecd.TBL_CUSTOMER AS C
ON A.customer_id = C.customer_id ;
EOF
